﻿using System;
using System.Windows;
using LEDHelper;
namespace LEDContract
{
    public class InsigmaLED
    {
        //ExportDll.exe  D:\SkyDrive\SXCPlatform\Lib\InsigmaLEDDriver.dll /debug /anycpu
        public static WXLED wx = new WXLED();
        #region====Defination======
        static int nLEDID = 1;
        #region=========Program================
        private static void LEDTest()
        {
            try
            {
                LED_LEDScreenInit(nLEDID, LEDAPI.DEVICE_TYPE_UDP, 238, 32);
                string szBackBMP = System.IO.Path.Combine(PathHelper.ApplicationPath, @"LPhoto\" + "A2.jpg");
                //szBackBMP = @"D:\LPhoto\A2.jpg";
                /*
method: 显示方式
* 1.   立即显示 2.   左滚显示    3.   连续上滚   4.   中间向上下展开   5.   中间向两边展开   6.   中间向四周展开   7.   向左移入
* 8.   向右移入   9.   从左向右展开  10.   从右向左展开  11.   右上角移入  12.   右下角移入  13.   左上角移入  14.   左下角移入
* 15.   从上向下移入  16.   从下向上移入  17.   闪 烁
* speed:   显示速度（1-8）越大越快
* transparent: 是否透明   0=不透明 1=透明

                int method = 1;
                switch (nEffectType)
                {
                    case 0:      method = 1;
                    case 1:   method = 2;
                    case 3: method = 8;
                 * case 4:   method = 16;
                    case 5:   method = 17;
                    default: method = nEffectType;
                        break;
                }*/
                /*
                LED_BeginProgram(nLEDID, 2000, szBackBMP);
                AddTextBlock_Click("111111", 10, 2, 128, 32, 11, 1); 
                LED_BeginProgram(nLEDID, 2000, szBackBMP);
                AddTextBlock_Click("141414", 10, 2, 128, 32, 14, 1);
                LED_BeginProgram(nLEDID, 2000, szBackBMP);
                AddTextBlock_Click("151515", 10, 2, 128, 32, 15, 1);
                LED_BeginProgram(nLEDID, 2000, szBackBMP);
                AddTextBlock_Click("161616", 10, 2, 128, 32, 16, 1);*/
               /*
                //上滚文字=4
                LED_BeginProgram(nLEDID, 2000, szBackBMP);
                AddTextBlock_Click("上滚文字,x=10,y=2,宽=128,高=32,速度=1", 10, 2, 128, 32, 4, 1);
                //下滚文字=16
                LED_BeginProgram(nLEDID, 2000, szBackBMP);
                AddTextBlock_Click("下滚文字", 10, 2, 128, 32, 16, 1);
                //立即显示文字=1
                LED_BeginProgram(nLEDID, 1000, szBackBMP);
                AddTextBlock_Click("立即显示文字,x=10,y=2,宽=128,高=32,速度=1", 10, 2, 128, 32, 0, 1);
                //左滚文字=2
                LED_BeginProgram(nLEDID, 300, szBackBMP);
                AddTextBlock_Click("左滚文字,x=10,y=2,宽=128,高=32,速度=1", 10, 2, 128, 32, 2, 1);
                //右滚文字=9
                LED_BeginProgram(nLEDID, 300, szBackBMP);
                AddTextBlock_Click("右滚文字,x=10,y=2,宽=128,高=32,速度=1", 10, 2, 128, 32, 9, 1);
            
                */
                //立即显示文字=1
                LED_BeginProgram(nLEDID, 1000, szBackBMP);
                AddTextBlock_Click("立即显示图片,x=10,y=2,宽=128,高=32,速度=1", 10, 2, 128, 32, 0, 1);
                LED_BeginProgram(nLEDID, 100, szBackBMP);
                AddBmpBlock_Click("A1.jpg", 10, 2, 128, 32, 0, 1);

                //左滚文字=2
                LED_BeginProgram(nLEDID, 300, szBackBMP);
                AddTextBlock_Click("左滚图片", 10, 2, 128, 32, 1, 1);
                LED_BeginProgram(nLEDID, 100, szBackBMP);
                AddBmpBlock_Click("A1.jpg", 10, 5, 128, 32, 1, 1);
                //右滚文字=9
                LED_BeginProgram(nLEDID, 300, szBackBMP);
                AddTextBlock_Click("右滚图片", 10, 2, 128, 32, 2, 1);
                LED_BeginProgram(nLEDID, 100, szBackBMP);
                AddBmpBlock_Click("A1.jpg", 10, 5, 128, 32, 2, 1); 
                //上滚文字=4
                LED_BeginProgram(nLEDID, 1000, szBackBMP);
                AddTextBlock_Click("上滚图片", 24, 5, 128, 32, 3, 1);                
                LED_BeginProgram(nLEDID, 100, szBackBMP);
                AddBmpBlock_Click("A1.jpg", 24,5, 128, 32, 3, 1);
                //下滚文字=16
                LED_BeginProgram(nLEDID, 2000, szBackBMP);
                AddTextBlock_Click("下滚图片", 10, 2, 128, 32, 4, 1);
                LED_BeginProgram(nLEDID, 2000, szBackBMP);
                AddBmpBlock_Click("A1.jpg", 0, 0, 64, 32, 4, 1);
                LED_BeginProgram(nLEDID, 2000, szBackBMP);
                AddBmpBlock_Click("A3.jpg", 64, 0, 128, 32, 1, 1);   
                LED_BeginProgram(nLEDID, 500, szBackBMP);
                AddClockBlockClick();  
                LED_EndProgram(nLEDID);
                LED_SendToScreen(nLEDID);
                //MessageBox.Show("Finish LED_SendToScreen(nLEDID);");
                LED_GetBright(nLEDID);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message);
            }
        }
        private static void AddBmpBlock_Click(string pic , int x1, int y1, int width, int height, int method, int speed)
        {
            try
            {
                int nLEDID = 1;
                string szBmpFile = System.IO.Path.Combine(PathHelper.ApplicationPath, @"LPhoto\" + pic);
                //MessageBox.Show(szBmpFile);
                //szBmpFile = @"D:\SXDFile\"+pic;
                //width238
                LEDBlock destRect = new LEDBlock();
                destRect.nHeight = height;
                destRect.nWidth = width;
                destRect.nStartX = x1;
                destRect.nStartY = y1;

                LEDBlock sourceRect = new LEDBlock();
                sourceRect.nHeight = 32;
                sourceRect.nWidth = 128;
                sourceRect.nStartX = 0;
                sourceRect.nStartY = 0;
                int nEffectType = method;
                int nSpeed = speed;
                Int32 lTrasnparent = 1;
                LED_AddBmpBlock(nLEDID, szBmpFile, destRect, sourceRect, nEffectType, nSpeed, lTrasnparent);
            }
            catch (Exception ex)
            {
                
            }
        }
        private static void AddTextBlock_Click(string text, int x1, int y1, int width, int height, int method,int speed)
        {
            try
            {
                string szText = text;
                LEDBlock rect = new LEDBlock();
                rect.nStartX = x1;
                rect.nStartY = y1;
                rect.nWidth = width;
                rect.nHeight = height;
                FontDescriptor lpFont = new FontDescriptor();
                lpFont.szFontName = "楷书";
                lpFont.lFontSize = 16;
                lpFont.lFontColor = 234;
                lpFont.nBold = 1;
                lpFont.nUnderline = 1;
                lpFont.nStrick = 1;
                int nEffectType = method;
                int nSpeed = speed;
                Int32 lTrasnparent = 1;
               LED_AddTextBlock(nLEDID, szText, rect, ref lpFont, 1, 1, nEffectType, nSpeed, lTrasnparent);
            }
            catch (Exception ex)
            {
            }
        }
        private static void AddClockBlockClick()
        {
            try
            {
                ClockDescriptor lpClock = new ClockDescriptor();

                LEDBlock rect = new LEDBlock();
                rect.nStartX = 0;
                rect.nStartY = 0;
                rect.nWidth = 128;
                rect.nHeight = 32;
                FontDescriptor lpFont = new FontDescriptor();
                //lpFont.szFontName = "楷书".ToCharArray;
                lpFont.szFontName = "楷书";
                lpFont.lFontSize = 14;
                lpFont.lFontColor = 234;
                lpFont.nBold = 1;
                lpFont.nUnderline = 1;
                lpFont.nStrick = 1;
                int nEffectType = 2;
                int nSpeed = 2;
                Int32 lTrasnparent = 1;
                LED_AddClockBlock(nLEDID, rect,ref lpClock, ref lpFont, nEffectType, nSpeed, lTrasnparent);

            }
            catch (Exception ex)
            {
            }
        }
        #endregion
        #endregion
        /// <summary>
        /// 3.1	动态链接库初始化:
        /// 定义：int InsigmaLEDDriver_Init( void ); 
        /// 功能：初始化动态链接库，将需要进行DLL初始化的代码放在这个函数中.
        /// 输入：无.
        /// 返回：成功返回0，失败返回-1
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("InsigmaLEDDriver_Init", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 InsigmaLEDDriver_Init()
        {
            Int32 result = -1;
            try
            {
                result = wx.InsigmaLEDDriver_Init();

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.2	清理动态链接库
        /// 定义：void InsigmaLEDDriver_Cleanup( void );
        /// 功能：卸载动态链接库，将需要进行DLL卸载的代码放在这个函数里，比如设备内存释放等
        /// 输入：无.
        /// 返回：无.
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("InsigmaLEDDriver_Cleanup", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 InsigmaLEDDriver_Cleanup()
        {
            Int32 result = 0;
            try
            {
                wx.InsigmaLEDDriver_Cleanup();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.3	检查LED设备是否正常
        /// 定义：int LED_IsDeviceOK( int nLEDID );
        /// 功能：检测指定的屏幕显示设备是否正常运行
        /// 输入：nLEDID - 设备ID；
        /// 返回：0表示正常， -1表示出现异常。
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_IsDeviceOK", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_IsDeviceOK(int nLEDID)
        {

            Int32 result = 0;
            try
            {
                LEDTest();
                result = wx.LED_IsDeviceOK(nLEDID);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.4	屏幕开关控制
        /// 定义: int LED_SwitchPower( int nLEDID, int nTurnOn );
        /// 功能：对远程显示屏设备进行开关控制
        /// 输入: nLEDID - 设备ID号
        /// nTurnOn – 1表示打开设备 0表示关闭设备
        /// 返回：成功返回0，失败返回-1
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_SwitchPower", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_SwitchPower(int nLEDID, int nTurnOn)
        {
            Int32 result = 0;
            try
            {
                result = wx.LED_SwitchPower(nLEDID, nTurnOn);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.5	检查设备是否开启
        /// 定义: int LED_IsDeviceTurnOn( int nLEDID );
        /// 功能：查询远程显示设备是否打开
        /// 输入: nLEDID – 设备ID号
        /// 返回: 0 表示关闭， 1表示打开
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_IsDeviceTurnOn", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_IsDeviceTurnOn(int nLEDID)
        {
            Int32 result = 0;
            try
            {
                result = wx.LED_IsDeviceTurnOn(nLEDID);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.6 检测设备是否离线
        /// 定义: int LED_IsDeviceOffline( int nLEDID );
        /// 功能: 检测指定的LED显示屏设备是否处于离线状态
        /// 输入: nLEDID – 设备ID号
        /// 返回: 0 表示离线 1 表示在线
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_IsDeviceOffline", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_IsDeviceOffline(int nLEDID)
        {

            Int32 result = 0;
            try
            {
                result = wx.LED_IsDeviceOffline(nLEDID);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.7 设置屏幕的亮度值
        /// 定义: int LED_SetBright( int nLEDID, int lValue );
        /// 功能: 设置指定显示屏的屏幕亮度
        /// 输入: nLEDID – 设备ID号
        /// lValue – 亮度值
        /// 返回：成功返回0，失败返回-1.
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_SetBright", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_SetBright(int nLEDID, int lValue)
        {
            Int32 result = 0;
            try
            {
                result = wx.LED_SetBright(nLEDID, lValue);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.7 设置屏幕的亮度值
        /// 定义: int LED_GetBright( int nLEDID);
        /// 功能: 设置指定显示屏的屏幕亮度
        /// 输入: nLEDID – 设备ID号
        /// lValue – 亮度值
        /// 返回：成功返回0，失败返回-1.
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_GetBright", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_GetBright(int nLEDID)
        {
            Int32 result = 0;
            try
            {
                result = wx.LED_GetBright(nLEDID);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.9	显示屏重启
        /// 定义: int LED_Restart( int nLEDID );
        /// 功能: 对指定的显示屏进行重启操作(重启后如果显示屏内含有固化的帧就显示固化数据，否则不显示)
        /// 输入： nLEDID - 设备ID；
        /// 返回：成功返回0，失败返回-1
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_Restart", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_Restart(int nLEDID)
        {
            Int32 result = 0;
            try
            {
                result = wx.LED_Restart(nLEDID);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.10	校对时钟
        /// 定义: int LED_AdjustCurrentTime( int nLEDID );
        /// 功能: 对指定的显示屏进行当前时间的校对，当显示屏显示的时间值不准确时，通过调用这个函数可以恢复当前精确时间
        /// 输入： nLEDID - 设备ID；
        /// 返回：成功返回0，失败返回-1
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_AdjustCurrentTime", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_AdjustCurrentTime(int nLEDID)
        {

            Int32 result = 0;
            try
            {
                result = wx.LED_AdjustCurrentTime(nLEDID);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.11	预加载位图资源
        /// 定义: int LED_PreUploadBMP( int nLEDID, const char *szBmpFile );
        /// 功能: 预先将指定的位图数据上传到指定的LED显示屏的存储器
        /// 输入: nLEDID - 设备ID号
        /// szBmpFile – 上传图片的完整路径(该完整路径为上传操作的机器上的路径，驱动应主动从给定路径上将该图片上传到控制器上) 
        /// 返回：成功返回0，失败返回-1
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_PreUploadBMP", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_PreUploadBMP(int nLEDID, string szBmpFile)
        {
            Int32 result = 0;
            try
            {
                result = wx.LED_PreUploadBMP(nLEDID, szBmpFile);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.12	删除预加载的位图
        /// 定义: int LED_RemoveUploadedBmp( int nLEDID, const char *szBmpFile );
        /// 功能: 从控制器上移除指定文件名的图片文件
        /// 输入: nLEDID – 设备ID号
        /// szBmpFile – 要移除的文件名(该文件名是已经上传到控制器里的图片的文件名称，非完整路径,控制器应能识别出该名称，并将它删除)
        /// 返回： 成功返回0，失败返回-1
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_RemoveUploadedBmp", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_RemoveUploadedBmp(int nLEDID, string szBmpFile)
        {
            Int32 result = 0;
            try
            {
                result = wx.LED_RemoveUploadedBmp(nLEDID, szBmpFile);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.13	获取剩余缓存空间
        /// 定义: int LED_GetFreeUploadBmpSpace( int nLEDID );
        /// 功能: 获取指定设备上的剩余的上传图片的缓存空间，以字节为单位
        /// 输入： nLEDID - 设备ID
        /// 返回: 以字节为单位的剩余空间
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_GetFreeUploadBmpSpace", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_GetFreeUploadBmpSpace(int nLEDID)
        {
            Int32 result = 0;
            try
            {
                result = wx.LED_GetFreeUploadBmpSpace(nLEDID);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.14	屏幕初始化
        /// 定义: int LED_LEDScreenInit( int nLEDID, int nScreenType, int nWidth, int nHeight );
        /// 功能: 在每一次准备向指定屏幕下发数据前，对屏幕进行的初始化操作调用
        /// 输入: nLEDID – 设备ID号
        /// nScreenType – 屏幕类型(目前为异步屏协议，该参数可忽略)
        /// nWidth – 屏幕宽度
        /// nHeight – 屏幕高度
        /// 返回：成功返回0，失败返回-1
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_LEDScreenInit", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_LEDScreenInit(int nLEDID, int nScreenType, int nWidth, int nHeight)
        {
            Int32 result = 0;
            try
            {
                result = wx.LED_LEDScreenInit(nLEDID, nScreenType, nWidth, nHeight);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.15	  添加一个节目(这里节目的意思是一屏的数据)
        /// 定义: int LED_BeginProgram( int nLEDID,  int lDisplayTime,const char *szBackBMP );
        /// 功能: 向指定的显示屏添加一个节目，如果向显示屏添加了多个节目，那么这些节目将自动轮流切换，切换的时间根据lDisplayTime参数的值，如果szBackBMP为NULL，那么不需要去加载背景图片，如果不为NULL，那么需要根据图片名称去加载一张图片.
        /// 输入: nLEDID – 设备ID号
        /// lDisplayTime – 当前节目的显示时间(以毫秒为单位)
        /// szBackBMP – 背景图片名称
        /// 返回：成功返回0，失败返回-1
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_BeginProgram", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_BeginProgram(int nLEDID, int lDisplayTime, string szBackBMP)
        {

            Int32 result = 0;
            try
            {
                if (lDisplayTime < 500)
                {
                    lDisplayTime = 1000;
                }
                wx.LED_BeginProgram(nLEDID, lDisplayTime, szBackBMP);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.16	添加文字区块
        /// 定义: void LED_AddTextBlock( int nLEDID, const char *szText, LEDBlock rect,LPFontDescriptor lpFont, int nHAlign,int nVAlign,int nEffectType, int nSpeed, int lTrasnparent );
        /// 功能: 向当前节目里添加一个文本区块
        /// 输入: nLEDID – 设备ID号
        /// szText – 该区块上显示的文本内容
        /// rect – 区块的区域范围
        /// lpFont – 区块的字体结构
        /// nHAlign – 文字水平对齐方式
        /// nVAlign – 文字垂直对齐方式
        /// nEffectType – 区块的特效方式
        /// nSpeed – 特效的速度(nEffectType>=2 and nEffectType<=5 表示移动的速度，nEffectType=6表示闪烁的频率)
        /// lTrasnparent – 是否透明显示
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_AddTextBlock", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_AddTextBlock(int nLEDID, string szText, LEDBlock rect, ref FontDescriptor lpFont, int nHAlign, int nVAlign, int nEffectType, int nSpeed, int lTrasnparent)
        {
            Int32 result = 0;
            try
            { 
                wx.LED_AddTextBlock(nLEDID, szText, rect, ref lpFont, nEffectType, nSpeed, lTrasnparent);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.17	添加位图区块
        /// 定义: void LED_AddBmpBlock( int nLEDID,const char *szBmpFile, LEDBlock destRect, LEDBlock sourceRect,int nEffectType,int nSpeed, int  lTrasnparent );
        /// 功能: 在当前节目内添加一个位图区块
        /// 输入: nLEDID – 设备ID号
        /// szBmpFile – 显示的存在于控制器上的位图名称
        /// destRect – 目标区域范围,即把位图显示在那个范围内
        /// sourceRect – 要显示的原图的区域范围
        /// nEffectType – 区块特效方式
        /// nSpeed -特效的速度(nEffectType>=2 and nEffectType<=5 表示移动的速度，nEffectType=6表示闪烁的频率)
        /// lTrasnparent – 背景透明
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_AddBmpBlock", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_AddBmpBlock(int nLEDID, string szBmpFile, LEDBlock destRect, LEDBlock sourceRect, int nEffectType, int nSpeed, int lTrasnparent)
        {
            //非常要注意双反斜杠c:\\TEMP\\qq.bmp
            Int32 result = 0;
            try
            {
                wx.LED_AddBmpBlock(nLEDID, szBmpFile, destRect, sourceRect, nEffectType, nSpeed, lTrasnparent);
                result = 0;
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.18	添加时钟区块
        /// 定义: void LED_AddClockBlock(int nLEDID, LEDBlock rect, LPClockDescriptor lpClock,LPFontDescriptor lpFont, int nEffectType, int nSpeed, int  lTrasnparent );
        /// 功能: 在当前节目内添加一个时钟区块
        /// 输入: nLEDID – 设备ID号
        /// rect – 时钟的区域范围
        /// lpClock – 时钟描述结构
        /// lpFont – 时钟显示的字体
        /// 以下3个参数忽略
        /// nEffectType –  
        /// nSpeed – 
        /// lTrasnparent – 
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_AddClockBlock", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_AddClockBlock(int nLEDID, LEDBlock rect, ref ClockDescriptor lpClock, ref FontDescriptor lpFont, int nEffectType, int nSpeed, int lTrasnparent)
        {
            Int32 result = 0;
            try
            {
                wx.LED_AddClockBlock(nLEDID, rect, ref lpClock, ref lpFont, nEffectType, nSpeed, lTrasnparent);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        /// <summary>
        /// 3.19	结束节目编辑
        /// 定义: long LED_EndProgram( int nLEDID );
        /// 功能: 结束对当前(和最近一次LED_BeginProgram调用匹配)节目的编辑，即表示一屏数据组织已经准备完毕.
        /// 输入: nLEDID – 设备ID号
        /// 返回：成功返回0，失败返回-1
        /// </summary>
        /// <returns></returns>
        [ExportDllAttribute("LED_EndProgram", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_EndProgram(int nLEDID)
        {

            Int32 result = 0;
            try
            {
                wx.LED_EndProgram(nLEDID);
                result = 0;
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        [ExportDllAttribute("LED_SendToScreen", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_SendToScreen(int nLEDID)
        {
            Int32 result = 0;
            try
            {
                result = wx.LED_SendToScreen(nLEDID);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
        [ExportDllAttribute("LED_FastenProgram", System.Runtime.InteropServices.CallingConvention.Winapi)]
        public static Int32 LED_FastenProgram(int nLEDID)
        {
            Int32 result = 0;
            try
            {
                result = wx.LED_FastenProgram(nLEDID);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return result;
        }
    }
}
